using NUnit.Framework;

namespace ValidationFramework.Tests
{
    public class RequiredObjectRuleTest
    {


        const string expectedInitialValue = "a";
        [TestFixture]
        public class Construction
        {
            [Test]
            public void Simple1()
            {
				var rule = new RequiredRule<object>
				           	{
				           		InitialValue = expectedInitialValue
				           	};
                Assert.AreEqual(expectedInitialValue, rule.InitialValue);
            }
         

            [Test]
            public void Simple2()
            {
                var rule = new RequiredRule<object>();
            }


            [Test]
            public void Simple3()
            {
                var rule = new RequiredRule<object>();
            }


            [Test]
            public void Simple4()
            {
                var rule = new RequiredRule<object>();
                Assert.IsNull(rule.ErrorMessage);
                Assert.IsFalse(rule.UseErrorMessageProvider);
            }
        }
        [TestFixture]
        public class Validate
        {
            [Test]
            public void Simple()
            {
                var rule = new RequiredRule<object>();
                rule.CheckType(new MockInfoDescriptor(typeof(object).TypeHandle, "foo"));

                Assert.IsFalse(rule.Validate(null, null, null, null));
                Assert.IsTrue(rule.Validate(null, "s", null, null));

            	var nullableRule2 = new RequiredStringRule
            	                    	{
            	                    		InitialValue = "a",
            	                    		IgnoreCase = true,
            	                    		TrimWhiteSpace = true
                                    	};
                Assert.IsFalse(nullableRule2.Validate(null, "a", null, null));
                Assert.IsTrue(nullableRule2.Validate(null, "s", null, null));
            }
        }
        [TestFixture]
        public class RuleInterpretation
        {
            [Test]
            public void Simple()
            {

                var nullableRule = new RequiredRule<object>();
                Assert.IsNotNull(nullableRule.RuleInterpretation);

            }
        }

    }
}